using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Boom : MonoBehaviour
{
    public float damageAmout = 10f;
    public float damageRadius = 1f;//半径
    PointEffector2D pointEffector2D;
    GameObject othergameobject;

    private void Start() {
        pointEffector2D.enabled = false;

    }
    private void OnTriggerStay2D(Collider2D other) {
        if(other.CompareTag("Player")){
            othergameobject = other.gameObject;
        }
        pointEffector2D.enabled = true;

        Invoke("DestroyMe",4f);
    }
    void Damage(){
            Vector2 playerPosition = othergameobject.transform.position;
            Vector2 centerPosition = transform.position;
            float distance = Vector2.Distance(playerPosition,centerPosition);
           // Debug.Log(distance);
            //判断是否有伤害
            if(distance<=damageRadius)
            {
                Debug.Log("damaging");
            }
        }
    

    void DestroyMe()
    {
        Destroy(gameObject);
    }
}
